
<template>
	<view >		
		<scroll-view scroll-y class="page">
			<cu-custom bgColor="bg-gradual-pink" :isBack="true">
				<block slot="backText"></block>
				<block slot="content">水费账单</block>				
			</cu-custom>
			<!-- list列表 -->
			<view style="padding: 0 10px 0  10px;">
			<view class="cu-list menu" >
				
				<view class="cu-item animation-slide-bottom" style="margin-top: 10px;" :style="[{animationDelay: '0.1s'}]">
					<view class="content">
						<text class="text-grey">缴费账号</text>
					</view>
					<view class="action">
						<text class="text-grey">{{billFormModel.accCode}}</text>
					</view>
				</view>
				<view class="padding0 flex flex-direction" :style="[{animationDelay: '0.3s'}]">
					
					<view class="action" >
						<my-date label="开始时间" v-model="billFormModel.createTimeBegin" placeholder="请选择开始时间" fields="day"></my-date>
					</view>
				</view>
				<view class="padding0 flex flex-direction" :style="[{animationDelay: '0.3s'}]">					
					<view class="action" >
						<my-date label="结束时间" v-model="billFormModel.createTimeEnd" placeholder="请选择结束时间" fields="day"></my-date>
					</view>
				</view>			
			</view>			
		</view>
		
		<view class="padding flex flex-direction" v-if="this.billFormModel.accCode !== '' ">
			<button class="cu-btn bg-green lg"  @click="onQuery">账单查询</button>
		</view>
		<view class="padding flex flex-direction" v-if="this.billFormModel.accCode == '' ">
			<button class="cu-btn bg-green lg"  @click="onBind">绑定账号</button>
		</view>
	

		</scroll-view>
	</view>
</template>

<script>
	import api from '@/api/api.js'
	import myDate from '@/components/my-componets/my-date.vue'
	export default {
		components:{
		    myDate
		 },
		data() {
			return {	
				loading: false,
				 billFormModel:{
					accCode:'',
					createTimeBegin:'',
					createTimeEnd:''
				}				
			};
		},
		onLoad() {
			let accCode=this.$store.getters.accCode;
			if(accCode){
				this.billFormModel.accCode=accCode;
			}
		},
		created(){
			this.init();
		},
		methods: {
			init(){
				this.billFormModel.createTimeBegin=this.getLastMonth();
				this.billFormModel.createTimeEnd=this.getToday();
			},
			onQuery(){
				if(this.billFormModel.accCode && this.billFormModel.createTimeBegin && this.billFormModel.createTimeEnd){
					this.$Router.push({name:'waterBillDetail', params:this.billFormModel})
				}else{
					this.$tip.toast('请填写条件');
					return;
				}
				/* uni.navigateTo({
				    url: '/pages/user/useredit?item='+item
				}); */
			},
			onBind(){
				this.$Router.push({name:'accBind'})
			},
			getToday() {
				var date = new Date(),
					year = date.getFullYear(),
					month = date.getMonth() + 1,
					day = date.getDate();
				month= month >= 1 && month <= 9 ? ("0" + month) : month;
				day = day >= 0 && day <= 9 ? ("0" + day) : day ;
				var timer = year + '-' + month + '-' + day;
				return timer;
			},
			getLastMonth() {
				var date = new Date(),
					year = date.getFullYear(),
					month = date.getMonth()+1;
					if(month == 1){
						year = year-1;
						month=12;
					}else{
						month=month-1;
						month= month >= 1 && month <= 9 ? ("0" + month) : month;
					}		
				var timer = year + '-' + month + '-01' ;
				return timer;
			}
		}
	}
</script>

<style>
	.uni-group {
		display: flex;
		align-items: center;
	}
	.padding0{
		padding: 0px;
	}	
</style>
